package com.class1.one.exer2;

import java.util.Scanner;

/**
 * 案例：输出英文星期几
 * <p>
 * 用一个数组，保存星期一到星期天的7个英语单词，从键盘输入1-7，显示对应的单词
 * {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}
 */
public class ArrayExer02 {
    public static void main(String[] args) {
        String weeks[] = {"Monday", "Tuesday", "Wednesday",
                "Thursday", "Friday", "Saturday", "Sunday"};
        //从键盘获取指定的数字，使用Scanner类  tab
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入星期几的数字(1-7)：");
        int day = scanner.nextInt();
        if (day < 1 || day > 7){
            System.out.println("输入的数字不正确");
        }else {
            System.out.println("星期" + weeks[day - 1]);
        }
        scanner.close();
    }
}
